const path = require('path')
module.exports = {
  // 1.配置方式一: CLI提供的属性
  outputDir: './dist',
  publicPath: process.env.NODE_ENV === 'development' ? '/' : './',
  devServer: {
    proxy: {
      '^/api': {
        target: 'https://www.baidu.com',
        pathRewrite: {
          '^/api': ''
        },
        changeOrigin: true
      }
    }
  },
  // 2.配置方式二: 和webpack属性完全一致,最后会合并
  // configureWebpack: {
  //   resolve: {
  //     alias: {
  //       components: '@/components'
  //     }
  //   }
  // }
  // configureWebpack: (config) => {
  //   config.resolve.alias = {
  //     '@': path.resolve(__dirname, 'src'),
  //     components: '@/components'
  //   }
  // }
  // 3.配置方式三
  chainWebpack: config => {
    config.resolve.alias
      .set('@', path.resolve(__dirname, 'src'))
      .set('components', '@/components')
      .set('assets', '@/assets')
      .set('utils', '@/utils')
      .set('network', '@/network')
      .set('views', '@/views')
      .set('store', '@/store')
  }
}
